<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户管理后台</title>
<style>
	.row-title{
	    width: 100%;
	    left: 0px;
	    position: relative;
	    height: 50px;
	    float: left;
	}
	
	.row {
	    width: 100%;
	    left: 0px;
	    position: relative;
	    height: 60px;
	    float: left;
	}
	
	.row-title .grid-title{
		width:100px;
		height:50px;
	    border: solid;
	    border-width: 1px;
	    padding-left: 10px;
	    padding-right: 10px;
	    float: left;
	    text-align: center;
	}
	
	.row .grid {
		width:100px;
		height:60px;
	    border: solid;
	    border-width: 1px;
	    padding-left: 10px;
	    padding-right: 10px;
	    float: left;
	    text-align: center;
	}
	
	.update-message{
	    height: 150px;
	    border: solid;
	    border-width: 1px;
	    width: 50%;
	    position: fixed;
	    top: 20%;
	    left: 25%;
	    background: #FFFFFF;
	    text-align: center;
	    line-height: 50px;
	    display: none;
	}
	
</style>
<script type="text/javascript" src="../static/js/jquery.min-1.11.3.js"></script>
</head>
<body>
	<div class="row-title">
		<form action="/showUser/" method="get">
		  <input type="hidden" name="pageNumber" value="0" />
		  <input type="text" name="searchContent" value="{{searchContent}}" />
		  <input type="submit" value="搜索" />
		</form>
		<a href='/cntIndex/'><button>数据统计</button></a>
		<a href='/showUserMessage/?userId=0&pageNumber=0'><button>查看所有用户详情</button></a>
		<a href='/userLoginIndex/'><button>登出</button></a>
	</div>
	<div class="row-title">
	 	<div class="grid-title">
			账号
			<br/>
			<a href= '/showUser/?pageNumber=0&isOrderByAccount=0' ><button>▲</button></a>
			<a href= '/showUser/?pageNumber=0&isOrderByAccount=1' ><button>▼</button></a>
		</div>
		<div class="grid-title">
			姓名
		</div>
		<div class="grid-title">
			性别
			<br/>
			<a href= '/showUser/?pageNumber=0&isOrderBySex=0' ><button>▲</button></a>
			<a href= '/showUser/?pageNumber=0&isOrderBySex=1' ><button>▼</button></a>
		</div>
		<div class="grid-title">
			年龄
			<br/>
			<a href= '/showUser/?pageNumber=0&isOrderByBirthday=0' ><button>▲</button></a>
			<a href= '/showUser/?pageNumber=0&isOrderByBirthday=1' ><button>▼</button></a>
		</div>
		<div class="grid-title">
			血糖类型
			<br/>
			<a href= '/showUser/?pageNumber=0&isOrderByCheckMessage=0' ><button>▲</button></a>
			<a href= '/showUser/?pageNumber=0&isOrderByCheckMessage=1' ><button>▼</button></a>
		</div>		
		<div class="grid-title">
			操作
		</div>											
	</div>
	{% for accgmUser in accgmUserList %}
		<div class="row">
		 	<div class="grid">
				{{accgmUser.username}}
				<br/>
				<button class="show-update-message" id="updateId{{accgmUser.id}}" >修改密码</button>
			</div>
			<div class="grid">
				{{accgmUser.name}}
			</div>
			<div class="grid">
				{% if accgmUser.sex == "M" %}
					男
				{% elif accgmUser.sex == "F" %}
					女
				{% endif %}
			</div>
			<div class="grid">
				{{accgmUser.birthday}}
			</div>
			<div class="grid">
				{% if accgmUser.checkmessage == 0 %}
					正常
				{% elif accgmUser.checkmessage == 1 %}
					1型
				{% elif accgmUser.checkmessage == 2 %}
					2型
				{% endif %}
			</div>		
			<div class="grid">
				<a href='/showUserMessage/?userId={{accgmUser.id}}&pageNumber=0'>详情</a>
			</div>											
		</div>
	{% endfor %}
	{% if size < 25 %}
		<div class="row">
			没有更多数据了
		</div>
	{% endif %}
	{% if previousPageUrl != '' %}
		<a href='{{previousPageUrl}}' ><button>上一页</button></a>
	{% endif %}
	{% if nextPageUrl != '' %}
		<a href='{{nextPageUrl}}' ><button>下一页</button></a>
	{% endif %}
	<div class="update-message">
		<input type="hidden" class="userId" value="" />
		密码：<input type="text" class="password" value="" />
		<br/>
		<button class="update-password">修改</button>
		<button class="close">取消</button>
	</div>
	<script>
		$('.show-update-message').click(function(){
			$('.update-message').show();
			$('.userId').val($(this).attr('id').replace('updateId',''))
		})
		$('.close').click(function(){
			$('.update-message').hide();
		})
		$('.update-password').click(function(){
		    $.ajax({  
		        type : "GET",  //提交方式  
		        url : "/updateUserPassword/",//路径  
		        data : {  
		            "userId" : $('.userId').val(),
		            "password" : $('.password').val(),
		        },//数据，这里使用的是Json格式进行传输  
		        success : function(result) {//返回数据根据结果进行相应的处理  
		            if(result.result == 1){
		            	alert(result.msg)	
		            	$('.update-message').hide();
		            }
		            else{
		            	alert(result.msg)
		            }
		        }  
		    });
		})
	</script>
</body>
</html>